home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AECUR100.ARJ / CMEMSRCH.C < prev    next >
Text File  |  1990-03-08  |  591b  |  30 lines

  1. /**********************************************************************
  2.  *  
  3.  *  cmemsrch.c
  4.  *  
  5.  *  copyright (c) 1988,89,90 J. Alan Eldridge
  6.  *
  7.  *  memsrchw() in C
  8.  *  
  9.  *  search an array of 2-byte values
  10.  *  
  11.  *********************************************************************/
  12.  
  13. void *
  14. memsrchw(
  15.     void    *buf,
  16.     void    *valp,
  17.     int     wcnt)
  18. {
  19.     short   wordval = *(short *)valp;
  20.     short   *wordptr = buf;
  21.     
  22.     while (wcnt-- > 0) {
  23.         if (*wordptr == wordval)
  24.             return wordptr;
  25.         wordptr++;
  26.     }
  27.  
  28.     return NULL;
  29. }
  30.